$(function () {
    var layer = null;
    var index = null;
    layui.use(["layer"], function () {
        layer = layui.layer;
    });
    //回车事件
    if (event.keyCode == 13) {//回车键的键值为13
        document.getElementByIdx_x("input").click();  //调用登录按钮的登录事件
    }
    //获得焦点效果
    $("#user").focus();
})
//登录
function Login() {
    var name = $("input[name='name']").val();
    var userPassword = $("input[name='userPassword']").val();
    // console.log("用户名：" + name + "密码：" + userPassword)
    requestAjax("login/login.htm", "post", "JSON", "name=" + name + "&userPassword=" + userPassword, function (data) {
        if (data.result) {
            layer.msg(data.msg);
            set(data.id);
            location.href = "view/welcome.html";
        } else {
            layer.msg(data.msg);
        }
    })
}

function set(id) {
    //由于是一个新的技术，你可以通过下面的代码检测你的浏览器是否支持
    if (window.localStorage) {
        //存储变量的值
        //localStorage.name = document.all.ide.value;
        localStorage.name = id;
        location.href = 'view/password.html';
    } else {
        alert("NOT SUPPORT");
    }
}
